for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
/**
* A module for a deck of cards.
*
* @module
*/
"use strict";
//const Card = require("../card/card");
class CardDeck {
* @constructor
* @param {object} options - Configure by sending options.
constructor(options = {}) {
this.numberOfDecks = options.numberOfDecks || 2;
this.numberOfCards = options.numberOfCards || 52;
this.decks = [];
for (let i = 0; i < this.numberOfDecks * 52; i++) {
this.decks.push(i % this.numberOfCards);
}
* Get number of cards in deck.
* @returns {integer} The amount of cards in the deck.
getNumberOfCards() {
return (this.decks.length);
* Show all cards by their id.
* @returns {array} With all cards.
showAllCardsById() {
return (this.decks.slice());
* Shuffle the deck.
* @returns {void}
shuffle() {
for (let i = this.decks.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[this.decks[i], this.decks[j]] = [this.decks[j], this.decks[i]];
i
/** global: i */
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.
j
/** global: j */
* Get a card from the deck, remove it from the deck.
* @returns {integer} As card id.
getCard() {
return (this.decks.pop());
module.exports = CardDeck;
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.